// run: $exec < input
// opt: 0
// flag: -g
#include <iostream>
#include <cmath>
#include <algorithm>

int const maxn = 3000007;
long long a[maxn];
int q1[maxn], q2[maxn]; // q1 for increase, q2 for decrease
long long k;
int n;

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n) {
		for (int i = 0; i < n; i++) std::cin >> a[i];
		if (n <= 1000) {
			for (int l = 1; l <= n; l++) {
				long long ans = 0;
				int h1 = 1, t1 = 0, h2 = 1, t2 = 0, left = 0;
				for (int i = 0; i < n; i++) {
					while (h1 <= t1 && a[i] <= a[q1[t1]]) t1--;
					while (h2 <= t2 && a[i] >= a[q2[t2]]) t2--;
					q1[++t1] = i;
					q2[++t2] = i;
					while (i - left + 1 > l) {
						if (q1[h1] == left) h1++;
						if (q2[h2] == left) h2++;
						left++;
					}
					ans = std::max(ans, a[q1[h1]] * a[q2[h2]]);
				}
				std::cout << ans << '\n';
			}
		} else {
			int t = 1000;
			for (int l = 1; l <= t; l++) {
				long long ans = 0;
				int h1 = 1, t1 = 0, h2 = 1, t2 = 0, left = 0;
				for (int i = 0; i < n; i++) {
					while (h1 <= t1 && a[i] <= a[q1[t1]]) t1--;
					while (h2 <= t2 && a[i] >= a[q2[t2]]) t2--;
					q1[++t1] = i;
					q2[++t2] = i;
					while (i - left + 1 > l) {
						if (q1[h1] == left) h1++;
						if (q2[h2] == left) h2++;
						left++;
					}
					ans = std::max(ans, a[q1[h1]] * a[q2[h2]]);
				}
				std::cout << ans << '\n';
			}
			long long max = 0, min = 1 << 30;
			for (int i = 0; i < t; i++) {
				max = std::max(max, a[i]);
				min = std::min(min, a[i]);
			}
			for (int i = t + 1; i <= n; i++)
				std::cout << max * min << '\n';
		}
	}
}

